<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('工人投诉具体情况列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>状态：</label>
                            <select name="status" th:with="type=${@dict.getType('sys_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>工地：</label>
                            <input type="text" name="projectName"/>
                        </li>
                        <li>
                            <label>分包单位：</label>
                            <input type="text" name="subLabourName"/>
                        </li>
                        <li>
                            <label>投诉时间：</label>
                            <input type="text" class="time-input" placeholder="请选择投诉时间" name="complainTime"/>
                        </li>
                        <li>
                            <label>投诉地点：</label>
                            <input type="text" name="complainPlace"/>
                        </li>
                        <li>
                            <label>投诉部门：</label>
                            <input type="text" name="complainDepartment"/>
                        </li>
                        <li>
                            <label>负责人：</label>
                            <input type="text" name="complainLeader"/>
                        </li>
                        <li>
                            <label>涉案金额：</label>
                            <input type="text" name="amountInvolved"/>
                            <span style=" position: absolute; top: 1%; right: 6%;color: #adadad; display: table-cell;white-space: nowrap; padding: 7px 10px;">万元</span>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="architecture:complain:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="architecture:complain:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="architecture:complain:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="exportExcel('importTplPerson','importPerson')" shiro:hasPermission="architecture:project:import">
                <i class="fa fa-download"></i> 导入(个人)
            </a>
            <a class="btn btn-warning" onclick="exportExcel('importTplTeam','importTeam')" shiro:hasPermission="architecture:project:import">
                <i class="fa fa-download"></i> 导入(集体)
            </a>
            <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="architecture:complain:export">
                <i class="fa fa-download"></i> 导出
            </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('architecture:complain:edit')}]];
    var removeFlag = [[${@permission.hasPermi('architecture:complain:remove')}]];
    var statusDatas = [[${@dict.getType('sys_status')}]];
    var delFlagDatas = [[${@dict.getType('sys_del')}]];
    var prefix = ctx + "architecture/complain";
    var projects = [[${projects}]];
    var labourSubs = [[${labourSubs}]];

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "工人投诉具体情况",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '记录id',
                    visible: false
                },

                {
                    field: 'projectId',
                    title: '工地',
                    formatter: function (value, row, index) {
                        let msg = value;
                        let bs = projects.filter(x => x.id == value);
                        if (!!bs && bs.length > 0) {
                            msg = bs[0].projectName;
                        }
                        return $.table.tooltip(msg);
                    }
                },
                {
                    field: 'subLabourId',
                    title: '劳务分包单位',
                    formatter: function (value, row, index) {
                        let msg = value;
                        let bs = labourSubs.filter(x => x.id == value);
                        if (!!bs && bs.length > 0) {
                            msg = bs[0].companyName;
                        }
                        return $.table.tooltip(msg);
                    }
                },
                {
                    field: 'complainTime',
                    title: '投诉时间'
                },
                {
                    field: 'complainPlace',
                    title: '投诉地点',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'complainDepartment',
                    title: '投诉部门',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'complainType',
                    title: '投诉类型'
                },
                {
                    field: 'complainLeader',
                    title: '负责人',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'complainMember',
                    title: '成员列表',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'complainContent',
                    title: '投诉内容',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    field: 'amountInvolved',
                    title: '涉案金额'
                },
                {
                    field: 'complainNumber',
                    title: '投诉人数'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function exportExcel(importTplId, importUrl) {
        var _width = "400";
        var _height = "230";
        top.layer.open({
            type: 1,
            area: [_width + 'px', _height + 'px'],
            fix: false,
            //不固定
            maxmin: true,
            shade: 0.3,
            title: '导入' + table.options.modalName + '数据',
            content: $('#' + importTplId).html(),
            btn: ['<i class="fa fa-check"></i> 导入', '<i class="fa fa-remove"></i> 取消'],
            // 弹层外区域关闭
            shadeClose: true,
            btn1: function (index, layero) {
                var file = layero.find('#file').val();
                if (file == '' || (!$.common.endWith(file, '.xls') && !$.common.endWith(file, '.xlsx'))) {
                    $.modal.msgWarning("请选择后缀为 “xls”或“xlsx”的文件。");
                    return false;
                }
                var index = top.layer.load(2, {shade: false});
                $.modal.disable();
                var formData = new FormData(layero.find('form')[0]);
                $.ajax({
                    url: prefix + '/' + importUrl,
                    data: formData,
                    cache: false,
                    contentType: false,
                    processData: false,
                    type: 'POST',
                    success: function (result) {
                        if (result.code == web_status.SUCCESS) {
                            $.modal.close(index);
                            $.modal.closeAll();
                            $.modal.alertSuccess(result.msg);
                            $.table.refresh();
                        } else if (result.code == web_status.WARNING) {
                            $.modal.close(index);
                            $.modal.enable();
                            $.modal.alertWarning(result.msg)
                        } else {
                            $.modal.close(index);
                            $.modal.enable();
                            $.modal.alertError(result.msg);
                        }
                    },
                    complete: function () {
                        layero.find('#file').val('');
                    }
                });
            }
        });
    }


</script>
</body>
<script id="importTplTeam" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果项目信息已经存在，更新这条数据。"> 是否更新已经存在的项目信息
                &nbsp; <a onclick="$.table.importExcelByUrl('architecture/complain/excelTeamTpl',false)" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
<script id="importTplPerson" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果项目信息已经存在，更新这条数据。"> 是否更新已经存在的项目信息
                &nbsp; <a onclick="$.table.importExcelByUrl('architecture/complain/excelPersonTpl',false)" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i>
                下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>